package com.terrace.controller.system;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.terrace.core.common.model.UserInfo;
import com.terrace.web.constant.GlobalsConstant;

/**
 * 跳转
 * @author jiangyg
 *
 */
@Controller
@Scope("prototype")
@RequestMapping("/forward")
public class ForwardController {
	
	/**
	 * 登录成功之后的主界面
	 * @param request
	 * @return
	 */
	@RequestMapping(params = "main")
	public ModelAndView main(HttpServletRequest request) {
		
		// 登录用户信息获取
		Session session =SecurityUtils.getSubject().getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(GlobalsConstant.USER_SESSION_KEY);
		if (userInfo != null) {
			request.setAttribute("loginUserInfo", userInfo);
		}
		
		return new ModelAndView("main/main");
	}
	
	/**
	 * 切换皮肤
	 * @param request
	 * @return
	 */
	@RequestMapping(params = "skin")
	public ModelAndView skin(HttpServletRequest request) {
		return new ModelAndView("main/skin");
	}

}
